if(!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.servers.dbProps.DbProperties")) {

    tibco.admin.Main.loadResource("tibco/admin/enterpriseAssets/servers/dbProps/jss/jss.xml", "tibco.admin", "jss22A", "ljss", false);
    /**
     * Machines
     */
    jsx3.lang.Package.definePackage("tibco.admin.enterpriseAssets.servers.dbProps", function (DbProperties) {
    });

    /**
     * Machines
     */
    jsx3.lang.Class.defineClass("tibco.admin.enterpriseAssets.servers.dbProps.DbProperties",
            jsx3.lang.Object,
            [tibco.admin.enterpriseAssets.servers.LeftNavInterface],
            function (plugin) {

                plugin.instance = null

                plugin.prototype.init = function() {
                    this.jsxsuper();
                }

                plugin.prototype.getNamespace = function() {
                    return "tibco.admin";
                }

                plugin.prototype.destroyPlugin = function() {
                }

                plugin.getInstance = function(args) {
                    if(!this.instance) {
                        this.instance = new tibco.admin.enterpriseAssets.servers.dbProps.DbProperties();
                    }
                    return this.instance;
                }

                plugin.prototype.loadComponent = function(parent) {
                    tibco.admin.Main.loadUIResourceAsync(parent, "tibco.admin", "tibco/admin/enterpriseAssets/servers/dbProps/components/dbConfig.xml");
                }

                plugin.prototype.getLeftText = function() {
                    return tibco.admin.Main.getServer().getDynamicProperty("@lbl_DBDetails_22A");
                }

                plugin.prototype.subscribeAll = function() {
                    this.callgetAdminClusterConfiguration();
                }

                plugin.prototype.editDBDetails = function(button) {
                    this.beginEditMode();
                    var buttonPane = button.getParent();
                    buttonPane.getChild("btnSaveDB_22A").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    buttonPane.getChild("btnCancelDB_22A").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true)
                    buttonPane.getChild("btnTestDB_22A").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true)
                    button.setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                    tibco.admin.Main.getServer().getJSXByName('blkSaveMessage_22A').setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    var dbworkspace = tibco.admin.Main.getServer().getJSXByName("blkDBDetails_22A");
                    var textboxes = dbworkspace.getDescendantsOfType(jsx3.gui.TextBox, false);
                    for(var i = 0; i < textboxes.length; i++) {
                        textboxes[i].setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                        textboxes[i].getParent().getChild(0).setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    }
                }

                plugin.prototype.resetEditDBDetails = function(button, saved) {
                    this.endEditMode();
                    var buttonPane = button.getParent();
                    buttonPane.getChild("btnSaveDB_22A").setEnabled(jsx3.gui.Form.STATEDISABLED, true).
                            setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    buttonPane.getChild("btnEditDB_22A").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true)
                    buttonPane.getChild("btnCancelDB_22A").setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                    buttonPane.getChild("btnTestDB_22A").setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                    tibco.admin.Main.getServer().getJSXByName('blkSaveMessage_22A').setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    var dbworkspace = tibco.admin.Main.getServer().getJSXByName("blkDBDetails_22A");
                    var textboxes = dbworkspace.getDescendantsOfType(jsx3.gui.TextBox, false);
                    for(var i = 0; i < textboxes.length; i++) {
                        var lbl = textboxes[i].getParent().getChild(0);
                        if(!saved && textboxes[i].getName() != "txtDBPassword_22A") {
                            textboxes[i].setValue(lbl.getText()).setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                        }
                        else {
                            lbl.setText(textboxes[i].getValue(), true);
                            textboxes[i].setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                        }
                        lbl.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);

                    }
                    var server = tibco.admin.Main.getServer();
		    server.getJSXByName("lblDBPassword_22A").setText(server.getDynamicProperty("@lblDBPassword_22A"), true);   
                }

                plugin.prototype.callgetAdminClusterConfiguration = function() {
                    if(!this.isInEditMode()) {
                        var objService = tibco.admin.Main.loadService("tibco.admin",
                                "tibco/admin/enterpriseAssets/servers/dbProps/rules/getAdminClusterPropertiesRules.xml",
                                "getAdminClusterConfiguration",
                                "get admin cluster configuration for DB details");
                        var me = this;
                        objService.subscribe(jsx3.net.Service.ON_SUCCESS, me, me.ongetAdminClusterConfigurationSuccess);
                        objService.setEndpointURL(tibco.admin.util.ServiceHelper.getAdminConfigurationEndpointURL())

                        objService.doCall();
                    }
                };

                plugin.prototype.ongetAdminClusterConfigurationSuccess = function(objEvent) {   //pluginCache_220 
	            var server = tibco.admin.Main.getServer();
		    server.getJSXByName("lblDBPassword_22A").setText(server.getDynamicProperty("@lblDBPassword_22A"), true);   
                };

                plugin.prototype.calltestDB = function() {
                    var objService = tibco.admin.Main.loadService("tibco.admin",
                            "tibco/admin/enterpriseAssets/servers/dbProps/rules/testDBConnectionRules.xml",
                            "testDB",
                            "test admin cluster configuration for DB details");
                    var me = this;
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, me, me.ontestDBSuccess);
                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getAdminConfigurationEndpointURL())
                    objService.doCall();
                };

                plugin.prototype.ontestDBSuccess = function(objEvent) {
                };

                plugin.trimString = function (string) {
                    return string.replace(/^\s*/, "").replace(/\s*$/, "");
                }

                plugin.prototype.callupdateDBConfiguration = function() {
                    var objService = tibco.admin.Main.loadService("tibco.admin",
                            "tibco/admin/enterpriseAssets/servers/dbProps/rules/updateDBDetailsRules.xml",
                            "updateDBConfiguration",
                            "update admin cluster configuration for DB details");
                    var me = this;
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, me, me.onupdateDBConfigurationSuccess);
                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getAdminConfigurationEndpointURL())
                    objService.doCall();
                };

                plugin.prototype.onupdateDBConfigurationSuccess = function(objEvent) {
                };

                plugin.prototype.getComponentPath = function() {
                    return "tibco/admin/enterpriseAssets/servers/dbProps/component.xml"
                }

                plugin.prototype.buttonSelected = function() {
                    this.callgetAdminClusterConfiguration();
                }
            });

}